import numpy as np
import random as rd
import drawNet as dn
def node_copy(m0, n, p, m):#节点复制模型
    G = np.empty((n, n))
    arr = []#array数组
    lst = [j for j in range(0, m0)]
    for i in range(m0, n):
        cnt = 0
        tmp_arr = arr.copy()
        tmp_lst = lst.copy()
        while(cnt < m):#连m条边
            cnt += 1
            r = rd.random()
            _rp = -1
            rp = rd.choice(tmp_lst)
            if(r < p and cnt < m):
                neb = []
                for j in tmp_lst:
                    if(G[rp][j] == 1):
                        neb.append(j)
                if(len(neb) != 0):
                    _rp = rd.choice(neb)
                    cnt += 1
            G[i][rp] = 1
            if(_rp != -1):
                G[i][_rp] = 1
                tmp_lst.remove(_rp)
            tmp_lst.remove(rp)
        lst.append(i)
    return G
dn.drawDiGraph(node_copy(3, 20, 0.3, 2))